package com.twu.biblioteca;

import java.util.ArrayList;

public class Customer {

    private String Id;
    private String name;
    private String emailAddress;
    private long phoneNumber;
    private String password;
    private ArrayList<Book> bookList;
    private ArrayList<Movie> movieList;

    public Customer(String id, String name, String emailAddress, long phoneNumber, String password) {
        Id = id;
        this.name = name;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        this.password = password;
        this.bookList=new ArrayList<Book>();
        this.movieList=new ArrayList<Movie>();
    }

    public ArrayList<Book> getBookList() {
        return bookList;
    }

    public ArrayList<Movie> getMovieList() {
        return movieList;
    }

    public void addBook(Book book)
    {
        this.bookList.add(book);
    }

    public void addMovie(Movie movie)
    {
        this.movieList.add(movie);
    }

    public void removeBook(String isbn)
    {
        for(Book book1:bookList)
        {
            if(book1.getIsbn().equalsIgnoreCase(isbn))
            {
                bookList.remove(book1);
                break;
            }
        }
    }

    public boolean equals(String id, String password)
    {
        if(this.Id.equalsIgnoreCase(id))
        {
            if(this.password.equalsIgnoreCase(password))
            {
                return true;
            }
        }
        return false;
    }
    public boolean searchBook(String isbn)
    {
        for(Book book1:bookList)
        {
            if(book1.getIsbn().equalsIgnoreCase(isbn))
            {
                return true;
            }
        }
        return false;
    }

    public boolean searchMovie(String name) {

        for(Movie book1:movieList)
        {
            if(book1.getName().equalsIgnoreCase(name))
            {
                return true;
            }
        }
        return false;
    }

    public void removeMovie(String name) {
        for(Movie movie1:movieList)
        {
            if(movie1.getName().equalsIgnoreCase(name))
            {
                movieList.remove(movie1);
                break;
            }
        }
    }

    public String getDetails() {
        return "Id :"+Id+"\nName :"+name+"\nEmail :"+emailAddress+"\nPhoneNumber :"+phoneNumber;

    }
}
